package com.itheima;

import java.util.Scanner;


public class CalculateArea {
    //计算圆形面积
    public static double calculateCircleArea(double radius) {
        return Math.PI * radius * radius;
    }

    //计算矩形面积
    public static double calculateRectangleArea(double length, double width) {
        // 矩形的面积公式为 长 * 宽
        return length * width;
    }

    //计算梯形面积
    public static double calculateTrapezoidArea(double topBase, double bottomBase, double height) {
        // 梯形面积公式：(上底 + 下底) * 高 / 2
        return (topBase + bottomBase) * height / 2.0;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入圆的半径:");
        double radius = scanner.nextDouble();
        double area = calculateCircleArea(radius);
        System.out.println("半径为 " + radius + " 的圆的面积是: " + area);
        System.out.println("-----------------------------------------");

        System.out.println("请输入矩形的长:");
        double length = scanner.nextDouble();
        System.out.println("请输入矩形的宽:");
        double width = scanner.nextDouble();
        double rectangleArea = calculateRectangleArea(length, width);
        System.out.println("长为 " + length + " 宽为 " + width + " 的矩形的面积是: " + rectangleArea);
        System.out.println("-----------------------------------------");

        System.out.println("请输入梯形的上底:");
        double topBase = scanner.nextDouble();
        System.out.println("请输入梯形的下底:");
        double bottomBase = scanner.nextDouble();
        System.out.println("请输入梯形的高:");
        double height = scanner.nextDouble();
        double trapezoidArea = calculateTrapezoidArea(topBase, bottomBase, height);
        System.out.println("上底为 " + topBase + " 下底为 " + bottomBase + " 高为 " + height + " 的梯形的面积是: " + trapezoidArea);
        scanner.close();
    }
}
